package test.service.impl;

import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.Session;
import javax.jms.TextMessage;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.jms.core.MessageCreator;
import org.springframework.stereotype.Service;

import test.service.ActivemqService;
@Service
public  class ActivemqServiceImpl implements ActivemqService {
	@Autowired
	private JmsTemplate jmsTemplate;

	public  void send() throws JMSException {
		jmsTemplate.send("firstQueue", new MessageCreator() {
			public Message createMessage(Session session) throws JMSException {
				TextMessage tm = session.createTextMessage();
				tm.setText("kkk");
				tm.setStringProperty("isLoan", "22");
				return tm;
			}
		});

	}	

	public void receive() {
		System.out.println(jmsTemplate.receive("firstQueue"));
	}

}
